Trò chơi Angry Birds trong UNITY Engine
31.707 lượt xem;
1 using System;
2
3
4 public static class GoEaseExponential
5 {
6 public static float EaseIn( float t, float b, float c, float d )
7 {
8 return ( t == 0 ) ? b : c * (float)Math.Pow( 2, 10 * ( t / d - 1 ) ) + b;
9 }
10
11 public static float EaseOut( float t, float b, float c, float d )
12 {
13 return ( t == d ) ? b + c : c * (float)( -Math.Pow( 2, -10 * t / d ) + 1 ) + b;
14 }
15
16 public static float EaseInOut( float t, float b, float c, float d )
17 {
18 if( t == 0 )
19 {
20 return b;
21 }
22 if( t == d )
23 {
24 return b + c;
25 }
26 if( ( t /= d / 2 ) < 1 )
27 {
28 return c / 2 * (float)Math.Pow( 2, 10 * ( t - 1 ) ) + b;
29 }
30 return c / 2 * (float)( -Math.Pow( 2, -10 * --t ) + 2 ) + b;
31 }
32 }
2
3
4 public static class GoEaseExponential
5 {
6 public static float EaseIn( float t, float b, float c, float d )
7 {
8 return ( t == 0 ) ? b : c * (float)Math.Pow( 2, 10 * ( t / d - 1 ) ) + b;
9 }
10
11 public static float EaseOut( float t, float b, float c, float d )
12 {
13 return ( t == d ) ? b + c : c * (float)( -Math.Pow( 2, -10 * t / d ) + 1 ) + b;
14 }
15
16 public static float EaseInOut( float t, float b, float c, float d )
17 {
18 if( t == 0 )
19 {
20 return b;
21 }
22 if( t == d )
23 {
24 return b + c;
25 }
26 if( ( t /= d / 2 ) < 1 )
27 {
28 return c / 2 * (float)Math.Pow( 2, 10 * ( t - 1 ) ) + b;
29 }
30 return c / 2 * (float)( -Math.Pow( 2, -10 * --t ) + 2 ) + b;
31 }
32 }